package  com.na.onlineservey.questionansweringoption


import com.docu.common.Action
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import com.na.onlineservey.QuestionAnsweringOptionService
import com.na.onlineservey.QuestionAnsweringOption

@Component("createQuestionAnsweringOptionAction")
class CreateQuestionAnsweringOptionAction extends Action {

  @Autowired
  QuestionAnsweringOptionService questionAnsweringOptionInstanceService

  public Object preCondition(Object params, Object object) {
    try {
      QuestionAnsweringOption questionAnsweringOptionInstance = (QuestionAnsweringOption) object
      if (!questionAnsweringOptionInstance.validate()) {
        return null
      }
      return questionAnsweringOptionInstance
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object execute(Object params, Object object) {
    try {
      return questionAnsweringOptionInstanceService.create(object)
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object postCondition(Object params, Object object) {
    return null
  }
}